export class Element {
  constructor(data, containTypes = []) {
    this.type = data.type
    //自身的块级
    this.chunks = [data]
    //子集
    this.list = []
    this.childs = containTypes
  }
  contain(elem) {
    if (elem.type == this.type) {
      this.addChunk(elem)
      if (this.list.length > 0) {
        return 3
      } else {
        return 1
      }
    } else if (this.isChild(elem)) {
      //this.addChild(elem)
      return 2
    } else {
      return 3
    }
  }
  isChild(elem) {
    return this.childs.indexOf(elem.type) > -1
  }
  addChild(elem) {
    this.list.push(elem)
    return this
  }
  addChunk(chunk) {
    this.chunks.push(chunk)
    return this
  }
}
export class ElementX extends Element {
  static type = 'x'
  constructor(data) {
    super(data)
  }
}
export class ElementA extends Element {
  static type = 'a'
  constructor(data) {
    super(data, ['a-1'])
  }
}
export class ElementA1 extends Element {
  static type = 'a-1'
  constructor(data) {
    super(data, [])
  }
}

export class ElementB extends Element {
  static type = 'b'
  constructor(data) {
    super(data, ['b-1'])
  }
}

export class ElementB1 extends Element {
  static type = 'b-1'
  constructor(data) {
    super(data, [])
  }
}

export class ElementC extends Element {
  static type = 'c'
  constructor(data) {
    super(data, [])
  }
}

export class ElementY extends Element {
  static type = 'y'
  constructor(data) {
    super(data, [])
  }
}

export default [ElementA, ElementX, ElementA1, ElementB, ElementB1, ElementC, ElementY]
